package com.shsxt.controller;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.jdom.JDOMException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alipay.api.AlipayApiException;
import com.shsxt.model.WCPayGetPrePayIdRespInfo;
import com.shsxt.service.ControllService;
import com.shsxt.service.WodeService;

import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;


@Controller
@RequestMapping("controll")
public class ControllController  {
	
	
	@Autowired
	private ControllService controllService;
	@Autowired
	private WodeService wodeService;
	 @RequestMapping(value="send")
	   	public  @ResponseBody Map<String, Object> send(String phoneNumber ) {
	    	Map<String, Object>  str= controllService.send(phoneNumber);
	       	return str;
	   	}
	 //控制端  随机生成兑换码
    @RequestMapping(value="cdkey")
   	public  @ResponseBody Map<String, Object> cdkey(String count ) {
    	Map<String, Object>  str= controllService.cdkey(count);
       	return str;
   	}
    //生成约满  
    @RequestMapping(value="create_yueman")
   	public  @ResponseBody Map<String, Object> create_yueman( ) throws ParseException {
    	Map<String, Object>  str= controllService.create_yueman();
       	return str;
   	}
  //微信登陆  
    @RequestMapping(value="weixin")
   	public  @ResponseBody Map<String, Object> weixing(String openid ) throws ParseException {
    	Map<String, Object>  str= controllService.weixin(  openid);
       	return str;
   	}
  //微信绑定手机  
    @RequestMapping(value="weixinbinding")
   	public  @ResponseBody Map<String, Object> weixinbinding(String type,String number,String phoneNumber,String openid,String head,String name,String sex ) throws ParseException, APIConnectionException, APIRequestException {
    	Map<String, Object>  str= controllService.weixinbinding(type,number, phoneNumber, openid,head, name, sex);
       	return str;
   	}
  //验证登陆TOKEN
    @RequestMapping(value="token")
   	public  @ResponseBody Map<String, Object> token(String phoneNumber,String token ) throws ParseException {
    	Map<String, Object>  str= controllService.token(phoneNumber,token);
       	return str;
   	}
  //首页轮播地址
    @RequestMapping(value="lunbo")
   	public  @ResponseBody Map<String, Object> lunbo( ) throws ParseException {
    	Map<String, Object>  str= controllService.lunbo();
       	return str;
   	}
 //支付宝购买会员卡
    @RequestMapping(value="buyVip")
   	public  @ResponseBody Map<String, Object> buyVip(String vip,String phoneNumber) throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException {
       	Map<String, Object> map = controllService.buyVip(vip,phoneNumber);
   		return map;
   	}
   	@RequestMapping(value="yzbuyVip")
   	public  @ResponseBody String yanzheng() throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException, AlipayApiException {
       	String map = controllService.yzbuyVip();
   		return map;
   	}
  //轮播图上传
    @RequestMapping(value="lunboup")
	public String   lunboup(HttpSession session,HttpServletRequest request,
			HttpServletResponse response) throws IllegalStateException, IOException, ParseException {
    	controllService.lunboup(session,request,response);
    	return "home";
	}
  //活动上传
    @RequestMapping(value="activityup")
   	public  String   activityup(String text,HttpSession session,HttpServletRequest request,
   			HttpServletResponse response) throws IllegalStateException, IOException, ParseException {
       	controllService.activityup(text,session,request,response);
       	return "home";
   	}
  //添加阿姨
    @RequestMapping(value="addAunt")
   	public  String   addAunt(HttpSession session,HttpServletRequest request,
   			HttpServletResponse response,String name,String age,String address,String idcard,String serviceType,String phoneNumber,String pwd,String honeLocation) throws IllegalStateException, IOException, ParseException {
       	controllService.addAunt(session,request,response,name, age, address, idcard, serviceType,phoneNumber, pwd,honeLocation);
       	return "home";
   	}
  //添加归属地
    @RequestMapping(value="addLocation")
   	public  String   addLocation(String location) throws IllegalStateException, IOException, ParseException {
       	controllService.addLocation(location);
       	return "home";
   	}
 
  //微信支付 订单
    @RequestMapping(value="wx")
   	public  @ResponseBody Map<String, Object> wx(String orderNumber,String type,String redeemCode  ) throws Exception {
       	Map<String, Object> map = controllService.wx( orderNumber, type, redeemCode );
   		return map;
   	}
  //微信验证 订单
    @RequestMapping(value="yzwx")
   	public  @ResponseBody String yzwx(HttpServletRequest request,HttpServletResponse response) throws IOException, JDOMException, ParseException  {
       	 controllService.yzwx(  request, response);
   		return null;
   	}
    //微信支付  会员卡
    @RequestMapping(value="wxVip")
   	public  @ResponseBody Map<String, Object> wxVip(String vip,String phoneNumber  ) throws Exception {
       	Map<String, Object> map = controllService.wxVip( vip, phoneNumber );
   		return map;
   	}
  //微信验证 会员卡
    @RequestMapping(value="yzwxVip")
   	public  @ResponseBody String yzwxVip(HttpServletRequest request,HttpServletResponse response) throws IOException, JDOMException, ParseException  {
       	 controllService.yzwxVip(  request, response);
   		return null;
   	}
    //微信验证 会员卡
    @RequestMapping(value="delete")
   	public  @ResponseBody String delete(String path)  {
       	 controllService.delete( path);
   		return null;
   	}
    //版本更新
    @RequestMapping(value="version")
   	public  @ResponseBody Map<String,Object> version()  {
       	Map<String ,Object>  map=controllService.version( );
   		return map;
   	}
    //版本更新
    @RequestMapping(value="versionAunt")
   	public  @ResponseBody Map<String,Object> versionAunt()  {
       	Map<String ,Object>  map=controllService.versionAunt( );
   		return map;
   	}
}
